package com.func.domain.activity.service.quota.policy.impl;

import com.func.domain.activity.model.aggregate.CreateQuotaOrderAggregate;
import com.func.domain.activity.model.valobj.OrderStateVO;
import com.func.domain.activity.repository.IActivityRepository;
import com.func.domain.activity.service.quota.policy.ITradePolicy;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * RebateNoPayTradePolicy
 * </p>
 *
 * @author Simon
 * @version 2025.03.23.1.0.0
 * @description
 * @since 2025-03-23
 */

@AllArgsConstructor
@Service("rebate_no_pay_trade")
public class RebateNoPayTradePolicy implements ITradePolicy {

    private final IActivityRepository activityRepository;

    @Override
    public void trade(CreateQuotaOrderAggregate createQuotaOrderAggregate) {
        // 不需要支付则修改订单金额为0, 状态为完成, 直接给用户账户充值
        createQuotaOrderAggregate.setOrderState(OrderStateVO.completed);
        createQuotaOrderAggregate.getActivityOrderEntity().setPayAmount(BigDecimal.ZERO);
        activityRepository.doSaveNoPayOrder(createQuotaOrderAggregate);
    }
}
